#include "vector_float2.h"


vector_float2::vector_float2(void)
{
	create_vector(0);
	this->vptr = nullptr;
}

vector_float2::vector_float2( int s )
{
	create_vector(s);
}

vector_float2::~vector_float2(void)
{
	delete_vector();
}

void vector_float2::create_vector( int s )
{
	this->vptr = std::unique_ptr<float>(new float[s]);
	this->size = s;
}

void vector_float2::delete_vector()
{
	this->size = 0;
}

void vector_float2::set( float value, int index )
{
	if( (index >= 0) && (index < this->size) )
	{
		this->vptr.get()[index] = value;
	}
}

void vector_float2::read_from_keyboard()
{
	float temp;

	if( this->size == 0 )
		return;

	for( int i = 0; i < this->size; i++ )
	{
		std::cout << "\nWrite a float to put at position " << i << " : ";
		std::cin >> temp;
		set( temp, i );
	}
}

void vector_float2::print()
{
	if( this->size == 0 )
		return;
	std::cout << "[";
	for( int i = 0; i < this->size -1 ; i++ )
	{
		std::cout << this->vptr.get()[i] << ",";
	}
	std::cout << this->vptr.get()[size-1];
	std::cout << "]";
}